package cn.sciento.core.swagger;

import org.springframework.http.HttpMethod;

import java.util.Arrays;
import java.util.StringJoiner;

public class PermissionData {
    private static final long serialVersionUID = -6503810120492682442L;
    private static final String GLOBAL_PERMISSION_CODE_TEMPLATE = "%s.%s.%s";
    private String path;
    private String method;
    private String description;
    private String code;
    private String action;
    private String permissionLevel;
    private String[] roles;
    private boolean permissionLogin;
    private boolean permissionPublic;
    private boolean permissionWithin;
    private boolean permissionSign;
    private String[] tags;
    private String status;
    private String upgradeApiPath;
    private HttpMethod upgradeApiMethod;
    private String resourceCode;

    public PermissionData() {
    }

    public String getPath() {
        return this.path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getMethod() {
        return this.method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public String getDescription() {
        return this.description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getCode() {
        return this.code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getAction() {
        return this.action;
    }

    public void setAction(String action) {
        this.action = action;
    }

    public String getPermissionLevel() {
        return this.permissionLevel;
    }

    public void setPermissionLevel(String permissionLevel) {
        this.permissionLevel = permissionLevel;
    }

    public String[] getRoles() {
        return this.roles;
    }

    public void setRoles(String[] roles) {
        this.roles = roles;
    }

    public boolean isPermissionLogin() {
        return this.permissionLogin;
    }

    public void setPermissionLogin(boolean permissionLogin) {
        this.permissionLogin = permissionLogin;
    }

    public boolean isPermissionPublic() {
        return this.permissionPublic;
    }

    public void setPermissionPublic(boolean permissionPublic) {
        this.permissionPublic = permissionPublic;
    }

    public boolean isPermissionWithin() {
        return this.permissionWithin;
    }

    public void setPermissionWithin(boolean permissionWithin) {
        this.permissionWithin = permissionWithin;
    }

    public boolean isPermissionSign() {
        return this.permissionSign;
    }

    public void setPermissionSign(boolean permissionSign) {
        this.permissionSign = permissionSign;
    }

    public String[] getTags() {
        return this.tags;
    }

    public void setTags(String[] tags) {
        this.tags = tags;
    }

    public String getStatus() {
        return this.status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getUpgradeApiPath() {
        return this.upgradeApiPath;
    }

    public void setUpgradeApiPath(String upgradeApiPath) {
        this.upgradeApiPath = upgradeApiPath;
    }

    public HttpMethod getUpgradeApiMethod() {
        return this.upgradeApiMethod;
    }

    public void setUpgradeApiMethod(HttpMethod upgradeApiMethod) {
        this.upgradeApiMethod = upgradeApiMethod;
    }

    public String getResourceCode() {
        return this.resourceCode;
    }

    public void setResourceCode(String resourceCode) {
        this.resourceCode = resourceCode;
    }

    public String getGlobalPermissionCode(String serviceName) {
        return String.format("%s.%s.%s", serviceName, this.resourceCode, this.code);
    }

    public String toString() {
        return "PermissionData{path='" + this.path + '\'' + ", method='" + this.method + '\'' + ", description='" + this.description + '\'' + ", code='" + this.code + '\'' + ", action='" + this.action + '\'' + ", permissionLevel='" + this.permissionLevel + '\'' + ", roles=" + Arrays.toString(this.roles) + ", permissionLogin=" + this.permissionLogin + ", permissionPublic=" + this.permissionPublic + ", permissionWithin=" + this.permissionWithin + ", permissionSign=" + this.permissionSign + ", tags=" + Arrays.toString(this.tags) + ", status='" + this.status + '\'' + ", upgradeApiPath='" + this.upgradeApiPath + '\'' + ", upgradeApiMethod=" + this.upgradeApiMethod + ", resourceCode='" + this.resourceCode + '\'' + '}';
    }
}
